package com.example.brazil_project.function;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.example.brazil_project.AddProductActivity;
import com.example.brazil_project.DucumentActivity;
import com.example.brazil_project.DucumentDetailActivity;
import com.example.brazil_project.RedactDocumentDetailActivity;
import com.example.brazil_project.parameter.Parameter;
import com.example.brazil_project.util.HttpUtil;
import com.example.brazil_project.util.IOUtil;
import com.example.brazil_project.util.ImageCutUtil;
import com.example.brazil_project.util.JSFunction;
import com.example.brazil_project.util.ParameterUtil;
import com.example.brazil_project.util.StringUtils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.webkit.WebView;

public class SearchProductFunction {
	Activity mContxt;  
	WebView webview;
	 public SearchProductFunction(Activity mContxt,Object webview) {  
	        this.mContxt = mContxt;  
	        this.webview = (WebView) webview;
	  }  
	 
	 /**
	  * 跟根据关键字获取产品
	  * @return
	  */
	 public String getProductByKeyword(){
		 Intent intent = mContxt.getIntent();
		 String keyword = intent.getStringExtra("keyword");
		 String order = intent.getStringExtra("order");
		 Map map = new HashMap();
		 map.put("keyword", keyword);
		 map.put("order", order);
		 String page = intent.getStringExtra("page");
		 Public_method public_method =new Public_method(mContxt);
		 String UserType = public_method.getLoginUserType();
		 String url = Parameter.getServerPath()+"APP/Product/getProductbyKeyword.nut?UserType="+UserType+"&page="+page;
		 String  msg = HttpUtil.doPost(url,map);
		// webview.loadUrl(JSFunction.getAlertMSGFunction(msg)); 
		return msg;
		 
	 }
	 /**
	  * 跟根据关键字获取自己的产品
	  * @return
	  */
	 public void getMyProductByKeyword(String keyword){
		 Intent intent = new Intent(mContxt, DucumentActivity.class);
		 Public_method p = new Public_method(mContxt);
			String name = p.getLoginUserName();
			intent.putExtra("username", name);
			intent.putExtra("keyword", keyword);
			mContxt.startActivity(intent); 
		
		 
	 }
	 
	 
}
